# apps/user_management/urls.py
from django.urls import path
from django.views.generic import TemplateView
from ninja import NinjaAPI
from .api.routers import main_router, admin_router, dispatch_router

# 创建API实例
api = NinjaAPI(
    title="用户管理API",
    version="1.0.0",
    docs_url="/docs/",  # 统一使用带斜杠的路径
    csrf=True
)

# 添加路由
api.add_router("/auth", main_router)          # /auth/register, /auth/login
api.add_router("/auth/admin", admin_router)    # /auth/admin/users
api.add_router("/auth/dispatcher", dispatch_router)  # /auth/dispatcher/dashboard

urlpatterns = [
    path("api/", api.urls),  # API路由
    path("login/", TemplateView.as_view(template_name="auth/login.html"), name="login"),
    path("register/", TemplateView.as_view(template_name="auth/register.html"), name="register"),
    path("dashboard/", TemplateView.as_view(template_name="dashboard.html"), name="dashboard"),
    path("", TemplateView.as_view(template_name="auth/login.html"), name="home"),  # 将登录页面设置为首页
]